﻿@using DTcms.Common;
@using DTcms.Model;
@{
    Layout = "~/Areas/admin/Views/Shared/_LayoutEdit.cshtml";
    ViewBag.Title = "url_rewrite_edit";
    List<SelectListItem> channelList = ViewData["channelList"] as List<SelectListItem>;
    List<SelectListItem> typeList = ViewData["typeList"] as List<SelectListItem>;
    DTcms.Model.url_rewrite m = ViewData["model"] as DTcms.Model.url_rewrite;
}
@section HeaderContent{
    <script>
        $(function () {
            //初始化表单验证
            $("#form1").initValidform();
            //添加按钮(点击绑定)
            $("#itemAddButton").click(function () {
                showUrlDialog();
            });
        });

        //创建窗口
        function showUrlDialog(obj) {
            var objNum = arguments.length;
            var d = top.dialog({
                title: 'URL配置信息',
                url: '../dialog_rewrite/index',
                onclose: function () {
                    var trHtml = this.returnValue;
                    if (trHtml.length > 0) {
                        $("#var_box").append(trHtml);
                    }
                }
            }).showModal();
            //检查是否修改状态
            if (objNum == 1) {
                d.data = obj;
            }
        }

        //删除节点
        function delUrlNode(obj) {
            $(obj).parent().parent().remove();
        }
    </script>
}
<form id="form1" method="post" action="SubmitSave?action=@ViewBag.Action&name=@ViewBag.UrlName">
    <!--导航栏-->
    <div class="location">
        <a href="../url_rewrite_list/index" class="back"><i class="iconfont icon-up"></i><span>返回列表页</span></a>
        <a href="../../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <a href="../url_rewrite_list/index"><span>URL配置</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>编辑URL配置</span>
        <div class="clipboard">
            <span><label id="clipMess"></label></span>
            <a href="javascript:;" class="copy" onclick="copy();"><i class="iconfont icon-copy"></i><span>复制</span></a>
            <a href="javascript:;" class="paste disable" onclick="paste();"><i class="iconfont icon-log"></i><span>粘贴</span></a>
        </div>
    </div>
    <div class="line10"></div>
    <!--/导航栏-->
    <!--内容-->
    <div id="floatHead" class="content-tab-wrap">
        <div class="content-tab">
            <div class="content-tab-ul-wrap">
                <ul>
                    <li><a class="selected" href="javascript:;">URL配置信息</a></li>
                </ul>
            </div>
        </div>
    </div>

    <div class="tab-content">
        <dl>
            <dt>所属频道</dt>
            <dd>
                <div class="rule-single-select">
                    @Html.DropDownList("ddlChannel", new SelectList(channelList, "Value", "Text", m.channel))
                </div>
                <span class="Validform_checktip">如果该页面不属于任何频道，可以忽略该项</span>
            </dd>
        </dl>
        <dl>
            <dt>页面类型</dt>
            <dd>
                <div class="rule-single-select">
                    @Html.DropDownList("ddlType", new SelectList(typeList, "Value", "Text", m.type), new { datatype = "*", sucmsg = " " })
                </div>
                <span class="Validform_checktip">*注意选择正确的面页类型</span>
            </dd>
        </dl>
        <dl>
            <dt>调用名称</dt>
            <dd>
                @Html.TextBox("txtName", m.name, new { @class = "input txt", datatype = @"/^[a-zA-Z0-9\-\_]{2,50}$/", sucmsg = " " })
                <span class="Validform_checktip">*调用该条URL配置信息的名称，不可重复</span>
            </dd>
        </dl>
        <dl>
            <dt>生成文件名</dt>
            <dd>
                @Html.TextBox("txtPage", m.page, new { @class = "input txt", datatype = "*", sucmsg = " " })
                <span class="Validform_checktip">*生成的视图页面名称，格式(页面名称/index)</span>
            </dd>
        </dl>
        <dl>
            <dt>继承类名</dt>
            <dd>
                @Html.TextBox("txtInherit", m.inherit, new { @class = "input txt", datatype = "*", sucmsg = " " })
                <span class="Validform_checktip">*该ASPX页面所要继承的类名(MVC下此项已经用不到)</span>
            </dd>
        </dl>
        <dl>
            <dt>模板文件名</dt>
            <dd>
                @Html.TextBox("txtTemplet", m.templet, new { @class = "input txt", datatype = "*", sucmsg = " " })
                <span class="Validform_checktip">*该页面的模板名称，扩展名一般是.cshtml</span>
            </dd>
        </dl>
        <dl>
            <dt>每页显示</dt>
            <dd>
                @Html.TextBox("txtPageSize", m.pagesize, new { @class = "input small", datatype = "n0-9", sucmsg = " " }) 条
                <span class="Validform_checktip">*当该页面进行分页时启用</span>
            </dd>
        </dl>
        <dl>
            <dt>URL表达式</dt>
            <dd>
                <a id="itemAddButton" class="icon-btn add"><i></i><span>添加表达式</span></a>
                <span class="Validform_checktip">*注意，不添加任何表达式则视为不重写</span>
            </dd>
        </dl>
        <dl>
            <dt></dt>
            <dd>
                <div class="table-container">
                    <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="100%">
                        <thead>
                            <tr>
                                <th width="30%">重写表达式</th>
                                <th width="30%">正则表达式</th>
                                <th width="30%">传输参数</th>
                                <th width="10%">操作</th>
                            </tr>
                        </thead>
                        <tbody id="var_box">
                            @foreach (DTcms.Model.url_rewrite_item item in m.url_rewrite_items)
                            {
                                <tr class="td_c">
                                    <td>
                                        <input type="text" name="itemPath" class="td-input" value="@item.path" style="width:90%;" readonly="readonly" />
                                    </td>
                                    <td>
                                        <input type="text" name="itemPattern" class="td-input" value="@item.pattern" style="width:90%;" readonly="readonly" />
                                    </td>
                                    <td>
                                        <input type="text" name="itemQuerystring" class="td-input" value="@item.querystring" style="width:90%;" readonly="readonly" />
                                    </td>
                                    <td>
                                        <a title="编辑" class="img-btn" onclick="showUrlDialog(this);"><i class="iconfont icon-edit"></i></a>
                                        <a title="删除" class="img-btn" onclick="delUrlNode(this);"><i class="iconfont icon-delete"></i></a>
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </dd>
        </dl>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <input type="submit" id="btnSubmit" value="提交保存" class="btn" />
            <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
        </div>
    </div>
    <!--/工具栏-->

</form>
